package com.itheima.Utils;

import com.itheima.pojo.Idcard;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class IdcardTypeHandler extends BaseTypeHandler<Idcard> {
    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, Idcard parameter, JdbcType jdbcType) throws SQLException {
        ps.setString(i, parameter.getCode()); // 设定数据库参数
    }

    @Override
    public Idcard getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return new Idcard(); // 返回一个实例，填充从数据库读取的值
    }

    @Override
    public Idcard getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return new Idcard(); // 返回一个实例，填充从数据库读取的值
    }

    @Override
    public Idcard getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return new Idcard(); // 返回一个实例，填充从数据库读取的值
    }
}
